<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-01-30 10:59:41
 * @Last Modified time: 2023-02-04 13:46:39
 */
namespace app\api\controller\store;	
use think\facade\App;
use app\api\services\store\GoodsService;
use app\common\services\store\GoodsCateService;
use app\common\services\store\GoodsCollectionService;

/**
 * Class Goods
 */
class Goods extends \app\api\controller\Base
{ 	
    /**
     * GoodsService constructor.
     * @param App $app
     */
    public function __construct(App $app,GoodsService $service)
    {
        parent::__construct($app);
        $this->service = $service;
    }

    /**
     * 获取商品详细
     * @force(false)
     * @method(GET)
     */
    public function detail(){
        $goodsId = $this->request->param('id');
        $detail = $this->service->getApiDetails($goodsId,$this->user);
        $this->success($detail);
    }

    /**
     * 获取商品规格
     * @method(GET)
     */
    public function sku(){
        $goodsId = $this->request->param('id');
        $data = $this->service->getDetailSku($goodsId,$this->user);
        $this->success($data);
    }

    /**
     * 获取商品列表
     * @force(false)
     * @method(GET)
     */
    public function list(){
        $data = $this->request->getMore([
            'cate_id'
        ]);
        $list = $this->service->getApiGoodsList($data,$this->user);
        $this->success('获取成功',$list);
    }

}
